package com.woniu.controller;

import com.woniu.config.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/ai")
@CrossOrigin
public class ChatController {
    @Autowired
    private ChatService chatService;

//    public ChatController(ChatService chatService) {
//        this.chatService = chatService;
//    }

//    @PostMapping(value = "/chat")
//    public ResponseResult chat(@RequestBody String userInput) {
//        Flux<String> s = chatService.processQuery(userInput);
//        System.out.println(s);
//        return ResponseResult.success(s);
//    }

    @PostMapping(value = "/chat")
    public Flux<String> chat(@RequestBody String userInput) {

        System.out.println("用户输入"+userInput);
        Flux<String> s = chatService.processQuery(userInput);

        return s;

    }




}
